import { privacyChannel } from "./privacyChannel";

/**
 * 
 *
 */
export class prv {


    /*
    //注入游戏
    cc.assetManager.loadBundle('privacy', (err, bundle) => {
        if (err) {
            console.error(err);
            return;
        }
        bundle.load('ruanzhu', cc.Prefab, (err, data) => {
            if (err) {
                console.error(err);
                return;
            }
            const node = cc.instantiate(data);
            node.parent = cc.director.getScene().getChildByName('Canvas');
        });
    });



    加隐私政策:
     if (!this.txt_jszc) {
        const node = new cc.Node();
        var lab = node.addComponent(cc.Label);
        lab.string = '隐私政策';
        lab.fontSize = 30;
        node.color = new cc.Color().fromHEX('#152BCB');
        node.on(cc.Node.EventType.TOUCH_END, () => {
            window.__prv.showPrivacy(false);
        }, this);
        this.txt_jszc = node;
        node.parent = this.node;
        node.setPosition(0, -150);
    }
    
    */



    /** 是否已经初始化 */
    static isInit: boolean = false;


    static init() {
        this.isInit = true;
        cc.sys.isBrowser = true; //强制浏览器模式
        console.error('=====>初始化prv', privacyChannel.channel);
        //@ts-ignore
        window.__prv = this;
        privacyChannel.init();
    }

    static showPrivacy(isToMain: boolean) {
        privacyChannel.showPrivacy(isToMain);
    }

    public static toast(txt: string, startY: number = 0) {
        privacyChannel.toast(txt, startY);
    }
    static kuangDian() {
        privacyChannel.getChannel().kuangDian();
    }
    static addVideo(parent: cc.Node, scale: number = 1, x: number = 0, y: number = 0) {
        privacyChannel.addVideo(parent, scale, x, y);
    }

    static showVideo(succ) {
        privacyChannel.getChannel().showVideo(succ);
    }
    static showNoRewardVideo() {
        privacyChannel.getChannel().showNoRewardVideo();
    }
    static hasPrivacy() {
        return privacyChannel.getChannel().hasPrivacy();
    }

    static showInter(isBanner: boolean = false, style?: any) {
        privacyChannel.getChannel().showInter(false, style);
    }

    static closeInter() {
        privacyChannel.getChannel().closeInter();
    }

    static showBanner() {
        privacyChannel.getChannel().showBanner();
    }

    static showHt() {
        privacyChannel.getChannel().showHt();
    }

    static getCtrl(key: string): number {
        return privacyChannel.getChannel().getCtrl(key);;
    }
    /** getSystemInfoSync */
    static getSysInfo(): any {
        return privacyChannel.getChannel().getSysInfo();
    }

    static closeKuangDian() {
        // setTimeout(()=>{
        //     privacyChannel.getChannel().showStyleInter(1);
        // }, 100);
    }


}
